define(['app', 'pagination', 'datetime', 'autocomplete', 'editor'], function(appCRM) {

    'use strict';
    /**
     * 客户信息360
     */
    appCRM.controller('View360', function($scope, dataFactoryCRM, $q, crmConst, $routeParams) {
        $scope.param;   //接收参数
        $scope.showType;//显示列表类型：付款、合同
        $scope.user_id; //用户id
        $scope.customer_id; //客户id
        $scope.servicedDay;   //累积服务时长
        $scope.onServicecCntract;    //服务中合同
        $scope.phoneLists;      //电话号码历史信息
        $scope.contact_info;    //联系信息
        $scope.contactLists;    //沟通记录
        $scope.payInfoTwoDate;  //最近两次付款信息
        $scope.payCount;   //付款次数
        $scope.contractInfoTwoDate; //最近两次合同信息
        $scope.contractCount;   //合同个数
        $scope.fukuanInfo;  //客户的所有付款信息
        $scope.customerinfo; //客户信息
        $scope.contactsInfo;    //合同信息
        $scope.infos;
        $scope.phoneCount;   //客户电话号码保存历史
        $scope.sextypes = [{ k: '1', v: '男' }, { k: '2', v: '女' }, { k: '3', v: '未知' }];
        $scope.FKrights;      //风控权限
        $scope.BErights;    //编辑基本信息权限
        $scope.SErights;    //编辑敏感信息权限
        $scope.SPErights;   //编辑服务人员权限
        $scope.selectePersonList = [{}];    //服务人员列表

        $scope.fukuanPages = { pageAll: 1, pageNow: 1, pageSize: $scope.psize, k: 3 };  //付款信息分页
        $scope.contractPages = { pageAll: 1, pageNow: 1, pageSize: $scope.psize, k: 3 };   //合同信息分页

        /*沟通记录中*/
        $scope.complainPages = { pageAll: 1, pageNow: 1, pageSize: 3, k: 3 };    //400记录分页
        $scope.complainData;  //400记录信息
        $scope.complainCount; //400记录个数
        $scope.riskPages = { pageAll: 1, pageNow: 1, pageSize: 3, k: 3 };    //追踪记录分页
        $scope.wenjuanPages = { pageAll: 1, pageNow: 1, pageSize: 3, k: 3 };    //问卷记录分页
        $scope.riskData;  //追踪记录信息
        $scope.riskCount; //追踪记录个数
        $scope.dailyPhonePages = { pageAll: 1, pageNow: 1, pageSize: 3, k: 3 };    //日常通话记录分页
        $scope.dailyPhoneData;  //日常通话记录信息
        $scope.dailyPhoneCount; //日常通话记录个数
        $scope.dailyContactPages = { pageAll: 1, pageNow: 1, pageSize: 3, k: 3 };    //日常通话记录分页
        $scope.dailyContactData;  //日常通话记录信息
        $scope.dailyContactCount; //日常通话记录个数

        $scope.educationTypes = crmConst.EDUCATION;   //教育程度
        $scope.careerTypes = crmConst.CAREER;       //职业

        /* 获取客户customer_id、用户user_id */
        $scope.getIds = function() {
            var customerID = $routeParams.customerID;
            if(customerID.indexOf('_') != -1){
                $scope.customer_id = customerID.split('_')[0];
                $scope.showType = customerID.split('_')[1];
            }else
                $scope.customer_id = customerID;
        };
        /*获取客户基本信息top*/
        $scope.showInfo = function(){
            var infoUrl = 'View360/index?customer_id=' + $scope.customer_id;
            dataFactoryCRM.getDataByAPI(infoUrl).then(function(data) {
                if(data.rcode){
                    $scope.customerinfo = data.custoInfo;
                    $scope.combinFromInfo = data.combinFromInfo;
                    $scope.combinFromInfoCount = $scope.combinFromInfo.length;
                    $scope.onServicecCntract = data.onServicecCntract;
                    $scope.onServiceCount = data.onServiceCount;
                    $scope.payInfoTwoDate = data.payInfoTwoDate;
                    $scope.payCount = data.payCount;
                    $scope.contractInfoTwoDate = data.contractInfoTwoDate;
                    $scope.contractCount = data.contractCount;
                    $scope.servicedDay = data.servicedDay;    
                }
            });
        }
        
        /*获取客户基本信息tab*/
        $scope.customerInfo = function(){
            var infoUrl = 'View360/customerInfo?id=' + $scope.customer_id;
            dataFactoryCRM.getDataByAPI(infoUrl).then(function(data) {
                if(data.rcode){
                    $scope.infos = data.infos;
                    $scope.phoneInfo = data.phoneInfo;
                    $scope.phoneCount = data.phoneCount;
                    $('#sex').dropdown('set selected', $scope.infos.sex);
                    $('#sex_input').dropdown('set selected', $scope.infos.sex);
                    $('#education').dropdown('set selected', $scope.infos.education);
                    $('#education_input').dropdown('set selected', $scope.infos.education);
                    $('#career').dropdown('set selected', $scope.infos.career);
                    $('#career_input').dropdown('set selected', $scope.infos.career);
                    for (var i = $scope.educationTypes.length - 1; i >= 0; i--) {
                        if($scope.infos.education == $scope.educationTypes[i]['k']){
                            $scope.infos.edu_name = $scope.educationTypes[i]['v'];
                        }
                    };
                    for (var i = $scope.careerTypes.length - 1; i >= 0; i--) {
                        if($scope.infos.career == $scope.careerTypes[i]['k']){
                            $scope.infos.car_name = $scope.careerTypes[i]['v'];
                        }
                    };
                }
            });
        }
        //监听电话号码:编辑电话号码，进行验证
        $scope.$watch('phone', function(newvalue, oldvalue) {
            if (newvalue != oldvalue) {
                $scope.phoneCheck();
            } 
        });

        $scope.phoneCheck = function(){
            var phone = $('#frm-edit input[name="phone"]').val();
            var reg = /^[0-9]+.?[0-9]*$/;
            if(phone && reg.test(phone) && phone.length < 7){
                $("#checkPhone").val('short');
            }else if(phone && reg.test(phone) && phone.indexOf('1') == 0 && phone.length != 11){
                $("#checkPhone").val('wrong');
            }else if(phone && phone.indexOf('1') == 0 && phone.length == 11){
                if(phone != $scope.infos.phone){
                    dataFactoryCRM.postDataByAPI('View360/checkPhone','customer_id='+$scope.customer_id+'&phone='+phone)
                    .then(function(d) {
                        if(d.rcode){
                            $("#checkPhone").val('exist');
                        }else{
                            $("#checkPhone").val('');
                        }
                    });
                }else{
                    $("#checkPhone").val('');
                }
            }else{
                $("#checkPhone").val('');
            }
        }

        /*编辑客户基本信息页面*/
        $scope.editCustomer = function(){
            //是否可编辑客户敏感信息
            if($scope.SErights){
                $("#frm-edit").form('reset');
                var infoUrl = 'View360/customerInfo?id=' + $scope.customer_id;
                dataFactoryCRM.getDataByAPI(infoUrl).then(function(data) {
                    $scope.edit_data = data.infos;
                    $('#frm-edit input[name="nickname"]').val($scope.edit_data.customername);
                    $('#frm-edit input[name="location"]').val($scope.edit_data.location);
                    $('#frm-edit input[name="sex"]').val($scope.edit_data.sexname);
                    $('#frm-edit input[name="mount"]').val($scope.edit_data.mount);
                    $('#frm-edit input[name="qq"]').val($scope.edit_data.qq);
                    $('#frm-edit input[name="weixin_id"]').val($scope.edit_data.weixin_id);
                    $('#frm-edit input[name="phone"]').val($scope.edit_data.phone);
                    $('#frm-edit input[name="birthday"]').val($scope.edit_data.birthday);
                    $('#frm-edit input[name="education"]').val($scope.edit_data.education);
                    $('#frm-edit input[name="career"]').val($scope.edit_data.career);
                    $('#frm-edit input[name="source_name"]').val($scope.edit_data.source_name);
                    $('#frm-edit input[name="address"]').val($scope.edit_data.address);
                    $('#frm-edit input[name="remark"]').val($scope.edit_data.remark);
                    $("#editCustomer_id").val($scope.customer_id);
                    $('#editSexID').dropdown('set selected', $scope.edit_data.sex);
                    $('#career_edit').dropdown('set selected', $scope.edit_data.career);
                    $('#education_edit').dropdown('set selected', $scope.edit_data.education);
                    $('.ui.editCustomer').modal({
                        onApprove: function() {
                            if($('#frm-edit').form('is valid')){
                                $scope.saveCusChange($('#frm-edit').serialize()+'&editSenvInfo=true');
                            }else
                                return false;
                        }
                    }).modal('show');
                });
            }else{
            //非超级管理员弹窗提示
                $(".ui.modal.noRightEdit").modal('show');
                setTimeout(function() {
                    $('.ui.modal.noRightEdit').modal('hide')
                }, 3000);
            }
        }

        /*编辑客户基本信息功能*/
        $scope.saveCusChange = function(saveParm){
            dataFactoryCRM.postDataByAPI('View360/editCust',saveParm)
                .then(function(d) {
                    if(d.rcode){
                        $(".ui.small.modal.editOk").modal('show');
                        setTimeout(function() {
                            $('.ui.small.modal.editOk').modal('hide')
                        }, 3000);
                        $scope.adutoLoading();
                    }else{
                        $(".ui.modal.editFail").modal('show');
                        setTimeout(function() {
                            $('.ui.modal.editFail').modal('hide')
                        }, 3000);
                        $scope.adutoLoading();
                        return false;
                    }
                });
        }

        /*点击编辑客户信息*/
        $scope.changeShow = function(param){
            if($scope.BErights){
                if(param == "birthdayOk"){
                $('#birthdayOk').hide();
                $('#birthdayNo').hide();
                $('#birthday_input').show();
            }
            $('#'+param).hide();
            $('#'+param).next().show();
            }
        }
        /*分别获取性别、出生年月、职业、受教育所选信息*/
        $scope.getParamValue = function(param,val){
            var paramUrl = 'customer_id='+$scope.customer_id+'&'+param+'='+val+'&'+param+'Edit='+'true';
            $scope.clickEditFun(paramUrl); //点击编辑功能
            $('#'+param).show();
            $('#'+param).next().hide();
        }
        $scope.getBirthValue = function(){
            $scope.newBirthVal = $("#birthEditVal").val();
        }
        $scope.$watch('newBirthVal', function(newvalue, oldvalue) {
            if (newvalue) {
                var param = 'customer_id='+$scope.customer_id+'&birthday='+newvalue+'&birthdayEdit=true';
                $scope.clickEditFun(param); //点击编辑功能
                $('#birthdayOk').show();
                $('#birthdayOk').next().hide();
                $("#birthday_input").hide();
            }
        });
        /*点击div之外空白位置，隐藏编辑div显示数据div*/
        $(document).bind('click', function () {
            $('#sex').show();
            $('#sex').next().hide();
            if($scope.infos.birthday){
                $('#birthdayOk').show();
                $('#birthdayOk').next().hide();
            }else{
                $('#birthdayOk').hide();
                $('#birthdayNo').show();
            }
            $("#birthday_input").hide();
            $('#education').show();
            $('#education').next().hide();
            $('#career').show();
            $('#career').next().hide();
            $('#remark').show();
            $('#remark').next().hide();
        });

        $('#remarkBox').on("dbclick",function(e){
            $('#remark').hide();
            $('#remark').next().show();
        })
         $('#remarkBox').on("click",function(e){
            //取消事件冒泡，点击事件不会同时触发document的点击事件
            if ( e && e.stopPropagation ){
                e.stopPropagation();
            } else{
                window.event.cancelBubble = true;
            }
        })
        //编辑备注信息后保存
        $scope.saveRemark = function(){
            var param = 'customer_id='+$scope.customer_id+'&remark='+$scope.infos.remark+'&remarkEdit=true';
            $scope.clickEditFun(param);
        }

        /*点击编辑可编辑区域*/
        $scope.clickEdit = function(caname,inputClass,content){
            $(caname).dblclick(function(){
                var td = $(this).children(inputClass);
                var name = $(this).children('.ui.input').attr('name');
                var txt = td.text();
                if(content){
                    var input= $(content);
                }else{
                    //编辑所在地、资金量、地址限制不同maxlength
                    if('location' == name)
                        var input = $("<input maxlength='20' type='text'value='" + txt + "'/>");
                    else if('mount'==name)
                        var input = $("<input maxlength='5' type='text'value='" + txt + "'/>");
                    else if('address'==name)
                        var input = $("<input maxlength='40' type='text'value='" + txt + "'/>");
                    else
                        var input = $("<input type='text'value='" + txt + "'/>");
                }
                td.html(input);
                input.dblclick(function(){ return false; }); 
                input.trigger("focus");
                input.blur(function() {
                    var newtxt = $(this).val();
                    if (newtxt != txt) {
                        td.html(newtxt);
                        var param = 'customer_id='+$scope.customer_id+'&'+name+'='+newtxt+'&'+name+'Edit=true';
                        $scope.clickEditFun(param); //点击编辑功能
                    } else { 
                        td.html(newtxt);
                    }
                });
            }); 
        }
        $scope.clickEdit(".field",".cus_edit");

        /*点击编辑功能*/
        $scope.clickEditFun = function(param){
            dataFactoryCRM.postDataByAPI('View360/editCust',param)
                .then(function(d) {
                    if(!d.rcode){
                        setTimeout(function(){
                            $(".ui.modal.editFail").modal('show');
                         },1000)
                        setTimeout(function() {
                            $('.ui.modal.editFail').modal('hide')
                        }, 3000);
                        $scope.adutoLoading();
                        return false;
                    }else{
                        $scope.adutoLoading();
                        
                    }
                });
        }

        /*添加日常沟通记录的textarea失去焦点后隐藏错误提示*/
        $scope.hideError = function(){
            $('#showError').removeClass('ui basic red pointing prompt label transition visible');
            document.getElementById("showError").innerHTML = '';
        }
        /*添加沟通记录*/
        $scope.contentAdd;  //添加沟通记录
        $scope.addContacts = function(){
            if ($scope.contentAdd) {
                $scope.hideError();  //输入沟通记录，隐藏错误提示
                var addContactUrl = 'customer_id=' + $scope.customer_id+'&content='+$scope.contentAdd;
                dataFactoryCRM.postDataByAPI('View360/addContact', addContactUrl).then(function(data) {
                    if (data.rcode) {
                        $scope.dailyContactInfo();
                        $scope.contentAdd = '';
                        $scope.dailyContactInfo();
                    } else {
                        setTimeout(function() {
                            $('.modalAdd').modal('show');
                            setTimeout(function() {
                                $('.modalAdd').modal('hide')
                            }, 3000)
                        }, 1000);
                        $scope.dailyContactInfo();
                        $scope.contentAdd = '';
                        return false;
                    }
                })
            }else{
                //沟通记录内容为空，出现错误提示
                $('#showError').addClass('ui basic red pointing prompt label transition visible');
                document.getElementById("showError").innerHTML = '请沟通记录不能为空！';
                return false;
            }
        }

        /*获取客户付款记录*/
        $scope.getFukuanList = function() {
            var _url = 'view360/getFukuan?p=' + $scope.fukuanPages.pageNow + '&psize=' + $scope.fukuanPages.pageSize + '&customer_id=' + $scope.customer_id;
            dataFactoryCRM.getDataByAPI(_url).then(function(data) {
                $scope.rcode_fukuan = data.rcode;
                $scope.fukuanPages.pageSize = data.psize;
                $scope.fukuanPages.pageAll = data.pall;
                $scope.fukuanPages.pageNow = data.p;
                $scope.fukuanInfo = data.data;
                $scope.fukuanCount = data.cnt;
            });
        };

        /*获取合同记录*/
        $scope.contractList = function(){
            var _url = 'view360/getContractList?p=' + $scope.contractPages.pageNow + '&psize=' + $scope.contractPages.pageSize + '&customer_id=' + $scope.customer_id;
            dataFactoryCRM.getDataByAPI(_url).then(function(data) {
                $scope.rcode_contract = data.rcode;
                $scope.contractPages.pageSize = data.psize;
                $scope.contractPages.pageAll = data.pall;
                $scope.contractPages.pageNow = data.p;
                $scope.contactsInfo = data.data;
                $scope.contactCount = data.count;
            });
        }

        /*获取400沟通记录*/
        $scope.complainInfos = function(){
            var infoUrl = 'View360/getComplainInfo?p=' + $scope.complainPages.pageNow + '&psize=';
            infoUrl = infoUrl + $scope.complainPages.pageSize + '&customer_id=' + $scope.customer_id;
            dataFactoryCRM.getDataByAPI(infoUrl).then(function(response) {
                $scope.complainRcode = response.rcode;
                $scope.complainData = response.data;
                $scope.complainCount = response.cnt;
                $scope.complainPages.pageSize = response.psize;
                $scope.complainPages.pageAll = response.pall;
                $scope.complainPages.pageNow = response.p;
            });
        }
        /*获取风险追踪记录*/
        $scope.riskInfos = function(){
            var infoUrl = 'View360/getRiskInfo?p=' + $scope.riskPages.pageNow + '&psize=';
            infoUrl = infoUrl + $scope.riskPages.pageSize + '&customer_id=' + $scope.customer_id;
            dataFactoryCRM.getDataByAPI(infoUrl).then(function(response) {
                $scope.riskRcode = response.rcode;
                $scope.riskData = response.data;
                $scope.riskCount = response.cnt;
                $scope.riskPages.pageSize = response.psize;
                $scope.riskPages.pageAll = response.pall;
                $scope.riskPages.pageNow = response.p;
            });
        }
        /*获取日常电话记录*/
        $scope.dailyPhoneInfo = function(){
            var infoUrl = 'View360/getPhoneInfo?p=' + $scope.dailyPhonePages.pageNow + '&psize=';
            infoUrl = infoUrl + $scope.dailyPhonePages.pageSize + '&customer_id=' + $scope.customer_id;
            dataFactoryCRM.getDataByAPI(infoUrl).then(function(response) {
                $scope.phoneRcode = response.rcode;
                $scope.dailyPhoneData = response.data;
                $scope.dailyPhoneCount = response.cnt;
                $scope.dailyPhonePages.pageSize = response.psize;
                $scope.dailyPhonePages.pageAll = response.pall;
                $scope.dailyPhonePages.pageNow = response.p;
            });
        }
        /*获取日常沟通*/
        $scope.dailyContactInfo = function(){
            $scope.hideError();     //默认隐藏错误提示
            var infoUrl = 'View360/getContactInfo?p=' + $scope.dailyContactPages.pageNow + '&psize=';
            infoUrl = infoUrl + $scope.dailyContactPages.pageSize + '&customer_id=' + $scope.customer_id;
            dataFactoryCRM.getDataByAPI(infoUrl).then(function(response) {
                $scope.dailyContactCount = response.cnt;
                $scope.contactRcode = response.rcode;
                $scope.dailyContactData = response.data;
                $scope.dailyContactPages.pageSize = response.psize;
                $scope.dailyContactPages.pageAll = response.pall;
                $scope.dailyContactPages.pageNow = response.p;
            });
        }

        /*获取问卷记录信息*/
        $scope.wenjuanInfo = function(){
            var infoUrl = 'View360/getWenjuanInfo?p=' + $scope.wenjuanPages.pageNow + '&psize=';
            infoUrl = infoUrl + $scope.wenjuanPages.pageSize + '&customer_id=' + $scope.customer_id;
            dataFactoryCRM.getDataByAPI(infoUrl).then(function(response) {
                $scope.wenjuanCount = response.cnt;
                $scope.wenjuanRcode = response.rcode;
                $scope.wenjuanData = response.data;
                $scope.wenjuanPages.pageSize = response.psize;
                $scope.wenjuanPages.pageAll = response.pall;
                $scope.wenjuanPages.pageNow = response.p;
            });
        }

        /*获取当前用户的编辑权限*/
        $scope.getRights = function(){
            dataFactoryCRM.getDataByAPI('View360/getRight').then(function(response){
                $scope.FKrights = response['fengkong']['rcode'];
                $scope.BErights = response['baseEdit']['rcode'];
                $scope.SErights = response['sensiEdit']['rcode'];
                $scope.SPErights = response['saleperEdit']['rcode'];
            });
        }

        /*编辑服务人员-监听输入内容*/
        $scope.personInputChanged = function($item) {
            $scope.detectPerson = $item;
        }
        
        /*服务人员双击、编辑事件*/
        $scope.changeSalPer = function(){
            if($scope.SPErights){
                $('#sales_person').hide();
                $('#sales_personname').show();
                $scope.detectPerson = $scope.customerinfo.sales_name;
                $("#sales_personname_value").val($scope.customerinfo.sales_name);
                $scope.$watch('detectPerson', function(newvalue, oldvalue) {
                    if (newvalue != oldvalue) {
                        $scope.person_newvalue = newvalue;
                        dataFactoryCRM.getDataByAPI('View360/getSalePersonInfo?nickname=' + $scope.detectPerson)
                            .then(function(d) {
                                if (d.rcode) {
                                    $scope.selectePersonList = d.data;
                                } else {
                                    $scope.selectePersonList = [{}];
                                }
                            });
                    }else
                        $scope.person_newvalue = $scope.detectPerson;
                });
            }
        }
        
        $scope.selectePerson = function(selected){
            if (selected){
                $("#sales_person_edit").val(selected.description.user_id);
                $scope.customerinfo.sub_company_name = selected.description.sub_companyname;
                $scope.sales_sub_company = selected.description.parent_company;
                //编辑服务人员
                $scope.editSalesPerson(selected.description.user_id,selected.description.parent_company);
            }else{
                $("#sales_person_edit").val('');
            }
        }
        /*失去光标*/
        $scope.focusOut = function(){
            //查询该服务人员是否存在
            dataFactoryCRM.getDataByAPI('view360/getSalePersonInfo?nickname='+$scope.person_newvalue+'&eq=true')
                .then(function(response) {
                    if(response.rcode){
                        //失去光标，服务人员存在则修改服务人员
                        $scope.editSalesPerson(response.data[0]['user_id'],response.data[0]['sector_id']);
                    }else{  //失去光标，服务人员不存在则显示原来数据
                        $('#sales_person').show();
                        $('#sales_personname').hide();
                    }
            });

        }


        /*修改客户服务人员*/
        $scope.editSalesPerson = function(sales_person,sales_sub_company){
            var infoUrl = 'view360/editSalesPerson?customer_id=' + $scope.customer_id;
            infoUrl = infoUrl+'&sales_person='+sales_person+'&sales_sub_company='+sales_sub_company;
            dataFactoryCRM.getDataByAPI(infoUrl).then(function(response) {
                if(!response.rcode){
                    setTimeout(function(){
                        $(".ui.modal.editFail").modal('show');
                     },1000)
                    setTimeout(function() {
                        $('.ui.modal.editFail').modal('hide')
                    }, 3000);
                    $scope.adutoLoading();
                    return false;
                }else{
                    $('#sales_person').show();
                    $('#sales_personname').hide();
                    $scope.adutoLoading();
                }
            });
        }

        /* 标签页切换 */
        $scope.first = function() {
            $scope.customerInfo();
        };
        $scope.second = function() {
            $scope.dailyPhoneInfo();
            if($scope.FKrights){
                $scope.complainInfos();
                $scope.riskInfos();
            }
            // $scope.weixinInfo();
            $scope.dailyContactInfo();
            $scope.wenjuanInfo();
        };
        $scope.complains = function(){
            $scope.complainInfos();     //400记录
        }
        $scope.risks = function(){
            $scope.riskInfos();         //风险追踪记录
        }
        $scope.wenjuan = function(){
            $scope.wenjuanInfo();         //问卷记录
        }
        $scope.weixin = function(){
            // $scope.weixinInfo();        //微信记录
        }
        $scope.dailyPhones = function(){
            $scope.dailyPhoneInfo();    //日常电话记录
        }
        $scope.dailyContacts = function(){
            $scope.dailyContactInfo();  //日常沟通记录
        }

        /*自动加载页面*/
        $scope.adutoLoading = function() {
            $scope.getIds();
            $scope.showInfo();
            $scope.getRights();
            $scope.first();
            $scope.getFukuanList();
            $scope.contractList();
        };
        $scope.adutoLoading();
    }).directive('payStatus', function() {
        return {
            restrict: 'A',
            template: "{{status}}",
            link: function(scope, element, attrs) {
                if (attrs.status) {
                    var code = scope.$eval(attrs.status);
                    var Names = ['待审核', '审核成功', '核失败'];
                    scope.status = Names[code];
                }
            }
        };
    }).directive('contractStatus', function() {
        return {
            restrict: 'A',
            template: "{{state}}",
            link: function(scope, element, attrs) {
                if (attrs.state) {
                    var code = scope.$eval(attrs.state);
                    code += 1;
                    var Names = ['合同取消', '待审核', '服务中','升级作废','到期','签订中'];
                    scope.state = Names[code];
                }
            }
        };
    });
});